import request from '@/utils/request'

export async function login(data) {
  return request({
    url: '/auth/oauth2/user/getToken',
    method: 'post',
    params: {
      username: data.username,
      password: data.password
    },
    headers: {
      client_id: 'webApp',
      client_secret: 'webApp'
    }
  })
}

export async function socialLogin(data) {
  return request({
    url: '/socialLogin',
    method: 'post',
    data
  })
}

export function getLoginUserInfo() {
  return request({
    url: '/basic/userInfo/getUserInfo',
    method: 'get',
    data: {
      // [tokenName]: accessToken,
    }
  })
  // const data = {roles: ["admin"], authorities:["READ", "WRITE", "DELETE"], username: 'admin', avatar: 'https://i.gtimg.cn/club/item/face/img/8/15918_100.gif'}
  // return data
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

export function register() {
  return request({
    url: '/register',
    method: 'post'
  })
}
